#ifndef __LIB_KERNEL_LIST_H__
#define __LIB_KERNEL_LIST_H__

#include "stdint.h"

#define offsetof(type, member) ( (uint32_t) (& ((type*)0)->member ) )
#define container_of(type, member, ptr) ( (type*) ( (char*)ptr - offsetof(type, member) ) )

struct list_item
{
	struct list_item* pre;
	struct list_item* next;
};

struct list
{
	struct list_item head;
	struct list_item tail;
};

void list_init(struct list* list);
void list_insert(struct list* list, struct list_item* item);
void list_remove(struct list_item* item);
void list_append(struct list* list, struct list_item* item);
void list_push(struct list* list, struct list_item* item);
struct list_item* list_pop(struct list* list);
int8_t list_empty(struct list* list);
uint32_t list_size(struct list* list);

#endif
